package com.gaoyi.crm.activity;

import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;

import androidx.activity.result.ActivityResult;

import com.gaoyi.crm.R;
import com.gaoyi.crm.activity.base.BaseViewActivity;
import com.gaoyi.crm.constant.SPName;
import com.gaoyi.crm.databinding.ActivityWelcomeBinding;
import com.gaoyi.crm.db.bean.Event;
import com.gaoyi.crm.util.AppUtil;
import com.gaoyi.crm.util.SPUtil;
import com.gaoyi.crm.util.WindowUtil;

import java.util.Map;

public class WelcomeActivity extends BaseViewActivity<ActivityWelcomeBinding> {

    @Override
    protected void initData() {
        WindowUtil.setWindowDecorView(this);
        mBinding.tvVersion.setText(getString(R.string.version,
                AppUtil.getVersion()));
        new Handler(Looper.getMainLooper()).postDelayed(() -> {
            if (TextUtils.isEmpty(SPUtil.getInstance().getString(SPName.TOKEN))) {
                startActivity(new Intent(mContext, LoginActivity.class));
            } else {
                startActivity(new Intent(mContext, MainActivity.class));
            }
            finish();
        }, 3000);
    }

    @Override
    protected ActivityWelcomeBinding getViewBinding() {
        return ActivityWelcomeBinding.inflate(getLayoutInflater());
    }

    @Override
    protected void event(Event event) {

    }

    @Override
    protected void onRequestPermissionsResult(Map<String, Boolean> result) {

    }

    @Override
    protected void onActivityResult(int requestCode, ActivityResult result) {

    }
}